package com.huqing.icu.controller.admin;

import com.huqing.icu.base.BaseController;
import com.huqing.icu.inout.req.admin.AdminCommunityPostApproveReq;
import com.huqing.icu.inout.req.admin.AdminCommunityPostListQueryReq;
import com.huqing.icu.service.admin.IAdminCommunityPostService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description 后台社区帖子相关接口
 * @Author huqing
 * @Date 2025/7/7 21:04
 **/
@RestController
@RequestMapping("/api-admin/community_post")
@Tag(name = "社区帖子接口")
public class AdminCommunityPostController extends BaseController {

    @Autowired
    private IAdminCommunityPostService iAdminCommunityPostService;

    @Operation(summary = "后台查询社区帖子列表")
    @RequestMapping(value = "/query_list", method = RequestMethod.POST, produces = "application/json")
    public String queryList(@RequestBody AdminCommunityPostListQueryReq queryReq, HttpServletRequest request) {
        Long userId = checkAndGetUserId(request);
        return jsonSuccessForNull(iAdminCommunityPostService.queryList(queryReq));
    }

    @Operation(summary = "后台查询社区帖子列表")
    @RequestMapping(value = "/batch_approve", method = RequestMethod.POST, produces = "application/json")
    public String batchApprove(@RequestBody AdminCommunityPostApproveReq approveReq, HttpServletRequest request) {
        Long userId = checkAndGetUserId(request);
        return jsonSuccessForNull(iAdminCommunityPostService.batchApprove(approveReq, userId));
    }
}
